
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCTest {
	public static void main(String[] args){
		try{
			Class.forName("com.mysql.jdbc.Driver");
			Connection conn=DriverManager.getConnection
					("jdbc:mysql://localhost:3306/school","root","MySQL");
			Statement stat=conn.createStatement();
			ResultSet rs=stat.executeQuery("select * from student");
			while(rs.next()){
				System.out.println(rs.getString("sname"));
				System.out.println(rs.getString("sId"));
			}
			conn.close();
			stat.close();
			rs.close();
		}catch (ClassNotFoundException e){
			e.printStackTrace();
		}catch (SQLException e){
			e.printStackTrace();
		}
	}
}